package test1;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		PersonSortable[] o = new PersonSortable[n];
		for (int i = 0; i < n; i++) {
			o[i] = new PersonSortable(in.next(), in.nextInt());
		}
		Arrays.sort(o);
		for (int i = 0; i < n; i++) {
			System.out.println(o[i]);
		}
		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
		in.close();
	}
}
